<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise</title>
</head>

<body>
    <script>
        // resolve reject all ract
        // resolve == then,reject == catch
        // let promise = new Promise((resolve, reject) => {
        //     resolve(111)
        // })
        // promise.then(response => {
        //     console.log('成功')
        //     console.log(response)
        // }).catch(error => {
        //     console.log('失败')
        //     console.log(error)
        // })

        // 链式
        function promise1(status) {
            return new Promise((resolve, reject) => {
                if (status) {
                    console.log('第一个promise成功')
                    resolve('第一个promi返回数据成功')
                }
                if (!status) {
                    console.log('第一个promise失败')
                    resolve('第一个promi返回数据失败')
                }
            })
        }
        promise1(true)
    </script>
</body>

</html>